package qualomelhor.game;

import static playn.core.PlayN.*;
import playn.core.GroupLayer;
import playn.core.Image;
import playn.core.ImageLayer;
import playn.core.Pointer;
import playn.core.ResourceCallback;
import org.jbox2d.collision.shapes.CircleShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.dynamics.FixtureDef;
import org.jbox2d.dynamics.World;
import qualomelhor.game.entities.DynamicPhysicsEntity;

public class PeaPhy extends DynamicPhysicsEntity {
	public static String TYPE = "Pea";
	private static Image image = loadImage("/images/pontoesq.png");
	// private static Image chrome = resolveImage("chrome.png");

	public PeaPhy(MyWorld myWorld, World world, float x, float y, float angle) {
		super(myWorld, world, x, y, angle);
	}

	@Override
	public Body initPhysicsBody(World world, float x, float y, float angle) {
		FixtureDef fixtureDef = new FixtureDef();
		BodyDef bodyDef = new BodyDef();
		bodyDef.type = BodyType.DYNAMIC;
		bodyDef.position = new Vec2(x, y);
		Body body = world.createBody(bodyDef);

		CircleShape circleShape = new CircleShape();
		circleShape.m_radius = getRadius();
		fixtureDef.shape = circleShape;
		fixtureDef.density = 5.4f;
		fixtureDef.friction = 0.1f;
		fixtureDef.restitution = 0.35f;
		circleShape.m_p.set(0, 0);
		body.createFixture(fixtureDef);
		body.setLinearDamping(0.2f);
		body.setTransform(new Vec2(x, y), angle);
		return body;
	}

	@Override
	public float getWidth() {
		return 2 * getRadius();
	}

	@Override
	public float getHeight() {
		return 2 * getRadius();
	}

	float getRadius() {
    	//return 1.50f;
		return 1.5f;
	}

	@Override
	public Image getImage() {
		return image;
    	//return chrome;
	}
}